package cn.fjc920.siaa.activityutils

import android.app.Activity

object ActivityCollector {

    //定义集合用于存储Activity
    private val activities = ArrayList<Activity>()

    //向集合中添加Activity
    fun addActivity(activity: Activity) {
        activities.add(activity)
    }

    //删除集合中指定的Activity
    fun removeActivity(activity: Activity) {
        activities.remove(activity)
    }

    //销毁程序中所有的Activity
    fun finishAll() {
        for (activity in activities) {
            //判断该Activity是否正在销毁
            if (!activity.isFinishing) {
                activity.finish()
            }
        }
        activities.clear()
    }

}